<?php
/**
 * User Preferences
 * 
 * It will display the list of layout preferences customization
 * 
 * @author Xavier VILAIN
 * @package Hive\User
 * @license #license-hive-social#
 */

use Fox\Html\DropList;
use Fox\Html\Block;
use Fox\Behaviors;
use Fox\Html\Input;
use Fox\Html\Screen;
use Hive\Ressource\Source\Parser\Linkedin;
use Fox\Html\Button;
use Fox\Generator;
use Fox\Html\Header\Content;
$xview = Xview::instance();
$id = $xview->application()->getId();
// Customizing
$customizing = Hive\User\Customizing::instance();
$customizing->trackSummaryPage(array('mod' => 'users','act'=>'preferences','sac' => null));

$user = User::current();
// Page Title
$header = new Fox\Html\Header\Content('page-header',Msg(Hive::BUNDLE,Hive::MENU_USER_PREFERENCES));

$html = Msg(Hive::BUNDLE,Hive::USER_PREFERENCES_HELP);
$html .= Xview::instance()->messages(true);

$screen = new Screen('sPreference','isave',null,true);
$screen->action(Generator::url('users','preferences'));
$blCountrySetting = new Block('countrySetting');
$blCountrySetting->add(new DropList(array('langu','language'),false,false,true))
			->options($xview->application()->languages(),'langu',Generator::call('description'));
$blCountrySetting->add(new DropList('dpara',false,true,false));
$blCountrySetting->add(new DropList('npara',false,true,false));
$screen->add($blCountrySetting);

// 

$screen->initialize(User::current()->getData());
if($screen->submitted()) {
	$fields = $screen->get();
	if(!$screen->errors()) {
		try {
			$user = User::current();
			$user->setFields($fields);
			$user->update();
			echo Msg(Fox\Msg::BUNDLE,Fox\Msg::MSG_SAVED_PREFERENCES);
			$screen->redirect(Generator::url('users','main'));
			return;
		} catch(Fox\Object\Exception\Save $e) {
			Fox\Message::Error($e);
		}
	}
	return $xview->messages(true,true);
	
}
 
$html.=$screen->display();
?>
<div>
	<div class="page-header clearfix"><?php echo $header->render();?></div>
	<div class="contentArea">
		<div class="mbs ">
			<?php echo $html;?>
		</div>
	</div>
</div>